package com.ecmcloud.resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ecmcloud.common.dto.Result;
import com.ecmcloud.entity.Dept;
import com.ecmcloud.service.IDeptService;
import com.ecmcloud.service.IOrgService;


@RestController
@RequestMapping(value = {"dept","api/dept"})
public class DeptResource {

    @Autowired
    private IDeptService deptService;

    @Autowired
    private IOrgService orgService;
    
    /**
     * 创建部门
     * @param dept 部门对象
     * @return
     */
    @PostMapping("create")
    public Result<String> create(@RequestBody Dept dept){
        return deptService.create(dept);
    }

    /**
     * 修改部门
     * @param dept 部门对象
     * @return
     */
    @PutMapping("update")
    public Object update(@RequestBody Dept dept){
        return deptService.updateDept(dept);
    }

    /**
     * 创建部门
     *
     * @param dept 部门对象
     * @return
     */
    @DeleteMapping("delete")
    public Object delete(@RequestBody Dept dept){
        return orgService.delete(dept);
    }


}
